#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import re
from dateutil.parser import parse

unit = {
    '百': 100,
    '千': 1000,
    '万': 10000,
    '亿': 100000000,
    '%': 0.01
}



def extract_number(string: str) -> float:
    '''提取字符串里的数字，有单位转化为无单位'''
    result = []
    numberStringList = re.findall(r"\d+\.?\d*", string)
    for numberString in numberStringList:
        index = string.find(numberString)
        if index - 1 >= 0 and string[index - 1] == '-':
            result.append(-float(numberString))
        try:
            unitKey = string[index + len(numberString)]
        except IndexError:
            result.append(float(numberString))
        else:
            result.append(float(numberString) * unit.get(unitKey, 1))
    return result[0]


def extract_date(s: str):
    return parse(s, fuzzy=True)


if __name__ == '__main__':
    print(extract_date('sdf202302130913发斯蒂芬'))
